package com.yshkj.payment.entity;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
 * 角色实体
 * 定义角色名称等信息
 * 角色和权限为:一个角色拥有多个权限,一个权限对应多个角色
 * Created by 唐旭 on 2016/9/7.
 */
@Entity
@Table
public class UserRole extends BaseDomain {
    //角色名称
    @Column
    private String name;
    //角色是否启用
    @Column
    private boolean enable = true;

    //权限
    @OneToMany(cascade = CascadeType.ALL)
    @JoinColumn(name = "user_role")
    private Set<UserPrivilege> privilegeSet = new HashSet<>();

    //角色关联的账号
    @OneToMany
    @JoinColumn(name = "user_role")
    private Set<UserAccountRole> accountRoleSet = new HashSet<>();

    public UserRole() {
    }

    public String getName() {
        return name;
    }

    public UserRole setName(String name) {
        this.name = name;
        return this;
    }

    public boolean isEnable() {
        return enable;
    }

    public UserRole setEnable(boolean enable) {
        this.enable = enable;
        return this;
    }

    public Set<UserPrivilege> getPrivilegeSet() {
        return privilegeSet;
    }

    public UserRole setPrivilegeSet(Set<UserPrivilege> privilegeSet) {
        this.privilegeSet = privilegeSet;
        return this;
    }

    public Set<UserAccountRole> getAccountRoleSet() {
        return accountRoleSet;
    }

    public UserRole setAccountRoleSet(Set<UserAccountRole> accountRoleSet) {
        this.accountRoleSet = accountRoleSet;
        return this;
    }
}
